Account Functions
To create functionality that manages you personal and team Epicenter accounts, leverage the Account adapter.
Importing the adapter
import { accountAdapter } from 'epicenter-libs';
The accountAdapter namespace exports functions that make calls to the Account API.
For descriptions of the objects used by the account adapter functions, read Account entities.
Create an account
Create a personal or team account.
export async function createAccount(
view: PersonalAccountCreateView | TeamAccountCreateView
): Promise<AccountReadView>
The function sends a POST request to the {accountShortName}/{projectShortName}/account endpoint setting the path parameters {accountShortName}='epicenter' and {projectShortName}='manager'.
The view parameter is serialized as the body of the API request.
Permissions
Requires a SYSTEM role.
Parameters
view (Union Type: PersonalAccountCreateView | TeamAccountCreateView): An object containing the account creation details. It can be either of the following types:
PersonalAccountCreateView: Represents the details required for creating a personal account.TeamAccountCreateView: Represents the details required for creating a team account.
Return value
A promise that resolves to an object of type AccountReadView. This object contains the details of the created account.
Get an account
Retrieve the details of an account by accountShortName.
export async function getAccount(accountShortName: string): Promise<AccountReadView>
The function sends a GET request to the /account endpoint.
Permissions
Requires a role of SUPPORT or higher.
Parameters
accountShortName (Type: string): Serves as the unique identifier of the account.
Return value
A promise that resolves to an object of type AccountReadView. This object contains the account's details retrieved from the server.
List team accounts
Retrieve a filtered list of team accounts which a specific admin has permission to access.
export async function teamForAdmin(
adminKey: string,
optionals: {
includeAllMembers?: boolean,
filter?: string,
first?: number,
max?: number,
} & RoutingOptions = {},
): Promise<AccountReadView[]>
Permissions
Requires a SYSTEM role.
Parameters
adminKey(type:string): A GUID that identifies the admin.optionals(optional, type:object): Filter, pagination, and routing options.includeAllMembers(boolean): IfTrue, includes all members of the team in the response.filter(string): A filter string to narrow down the results.first(number): Specifies the starting index for pagination.max(number): Defines the maximum number of results to return.RoutingOptions(object): An optional parameter providing additional routing options. Defaults to an empty object.
Return value
A promise that resolves to an array of AccountReadView objects, each representing a team account.
Update an account
Update account details.
export async function updateAccount(
view: PersonalAccountUpdateView | TeamAccountUpdateView,
optionals: RoutingOptions = {},
): Promise<AccountReadView>
The function sends a PATCH request to the /account endpoint.
Permissions
Requires a role of AUTHOR or higher.
Parameters
view(Union type:PersonalAccountUpdateView | TeamAccountUpdateView): An object containing the updated account details. It can be one of the following types:PersonalAccountUpdateView: Represents the fields required for updating a personal account.TeamAccountUpdateView: Represents the fields required for updating a team account.
optionals(optional, type:RoutingOptions): An optional parameter providing additional routing options. Defaults to an empty object.
Return value
A promise that resolves to an object of type AccountReadView, containing the updated account details.
Remove an account
Delete an account and all account details.
export async function removeAccount(accountShortName: string): Promise<void>
The function sends a DELETE request to the /account endpoint.
Permissions
Requires a role of OWNER or higher.
Parameters
accountShortName (Type: string): Serves as the unique identifier of the account.
Return value
A promise that resolves to void.